﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

using Toenda.Foundation;

namespace Toenda.Foundation.Messaging {
	/// <summary>
	/// Provides properties to get a list of internal messages sorted.
	/// </summary>
	public class MessageSortParam {
		/// <summary>
		/// Initialisiert ein neues <see cref="MessageSortParam"/> Objekt.
		/// </summary>
		public MessageSortParam() {
		}

		/// <summary>
		/// Initialisiert ein neues <see cref="MessageSortParam"/> Objekt.
		/// </summary>
		/// <param name="expression">
		/// Die Beschreibung. </param>
		public MessageSortParam(string expression)
			: this(expression, DataSortDirection.Ascending) { }

		/// <summary>
		/// Initialisiert ein neues <see cref="MessageSortParam"/> Objekt.
		/// </summary>
		/// <param name="expression">
		/// Die Beschreibung. </param>
		/// <param name="direction">
		/// Die Sortierrichtung. </param>
		public MessageSortParam(string expression, DataSortDirection direction) {
			this._direction = direction;
			this._expression = expression;
		}

		private DataSortDirection _direction;

		/// <summary>
		/// Gibt die Sortierichtung zurück, oder legt diese fest.
		/// </summary>
		public DataSortDirection Direction {
			get { return this._direction; }
			set { this._direction = value; }
		}

		private string _expression;

		/// <summary>
		/// Gibt die Beschreibung zurück, oder legt diese fest.
		/// </summary>
		public string Expression {
			get { return this._expression; }
			set {
				this._expression =
					value == null ? string.Empty : value;
			}
		}
	}
}
